function getPorpertyName(names, target) {
  return names.find(item => item in target);
}
const enterFullScreenName = getPorpertyName([
  'requestFullscreen ',
  'mozRequestFullScreen',
  'webkitRequestFullscreen',
  'msRequestFullscreen'
], document.documentElement);
const exitFullScreenName = getPorpertyName([
  'exitFullscreen',
  'mozCancelFullScreen',
  'webkitExitFullscreen',
  'msExitFullscreen'
], document);
const fullScreenName = getPorpertyName([
  'fullscreenElement',
  'mozFullScreenElement',
  'webkitFullscreenElement',
  'msFullscreenElement'
], document);

// 进入全屏
export function enter(ele) {
  enterFullScreenName && ele[enterFullScreenName]();
}
// 退出全屏
export function exit() {
  exitFullScreenName && document[exitFullScreenName]();
}
// 获取当前处于全屏的元素
export function fullEle() {
  return fullScreenName && document[fullScreenName] || null;
}
// 当前是否处于全屏
export function isFull() {
  return !!fullEle();
}
// 切换全屏
export function toggle(ele) {
  isFull() ? exit() : enter(ele);
}
